{layout name="layout" /}
{foreach $order as $key => $rs}
<div id="actionbar" class="fn-clear">
    {if $rs.paid_at == 1 && $rs.express_status == 0}
        {if $rs.is_entrust}
            <a href="javascript:openwin('{:url('fastshop/order/sendgoods',['order_no' =>$key])}')" class="button button-green">立即发货</a>
        {else}
            <button class="button" disabled>待确认</button>
        {/if}
    {else}
        <button class="button" disabled>立即发货</button>
    {/if}
    {if $rs.paid_at == 1 && $rs.express_status == 1 && $rs.status == 0}
        <button class="button bar button-green" url="{:url("fastshop/order/completion",['order_no'=>$key])}" msg="【结单？】查询单号确认用户已签收">结单</button>
    {else}
        <button class="button" disabled>结单</button>
    {/if}
    <div class="fn-right">
    {if $rs.paid_at == 0 && $rs.is_del ==0}
        <button class="button bar" url="{:url("fastshop/order/paid",['order_no'=>$key])}" msg="【修改订单？】确认要强制修改订单到付款状态？"><i class="iconfont icon-dollar"></i>人工确认付款</button>
        <button class="button bar" url="{:url("fastshop/order/delete",['order_no'=>$key])}" msg="【删除？】确认要删除当前订单"><i class="iconfont icon-lajixiang"></i>删除订单</button>
    {/if}
    </div>
</div>
<table class="pure-table">
    <thead>
        <tr class="pure-table-title">
            <td>{$rs.order_starttime} 订单号 : <i class="iconfont icon-wodedingdan2"></i>{$key}</td>
            <td colspan="2" class="fn-tar">
                {if $rs.is_del ==1}
                    <span class="badge">已删除</span>
                {else}
                    {if $rs.status == 1}
                        <span class="badge">已完成</span>
                    {else}
                        {if $rs.paid_at}
                            {if $rs.express_status}
                                <span class="badge bg-green">已发货</span>
                            {else}
                                {if $rs.is_entrust == 1}
                                    <span class="badge bg-blue">待发货 [ 已寄卖 ]</span>  
                                {elseif $rs.is_entrust == 2}   
                                    <span class="badge bg-blue">待发货 [ 不寄卖 ]</span>
                                {else}
                                    <span class="badge bg-yellow">待确认</span>
                                {/if}  
                            {/if}
                        {else}
                            <span class="badge bg-red">待付款</span>
                        {/if}
                    {/if}
                {/if}
            </td>
        </tr>
        <tr>
            <td>收货人：{$rs.express_name}&nbsp;/&nbsp;{$rs.express_phone}<br />收货地址：{$rs.express_address}</td>
            <td colspan="3">{if $rs.express_status}物流公司：{$rs.express_company}<br />{if $rs.express_no}快递单号：<a href="https://www.baidu.com/s?wd={$rs.express_no}" target="_blank" class="badge">{$rs.express_no}</a>{/if}{/if}</td>
        </tr>
        <tr><th>商品</th><th class="w140 fn-tac">单价</th><th class="w70 fn-tac">小计</th></tr>
    </thead>
    <tbody>
        <tr>
            <td>
                <div class="fn-clear order">
                    <div class="img fn-left"><img src="{$rs.item.img}?x-oss-process=style/80" /></div>
                    <a href="{:url('fastshop/item/edit',['id'=>$rs.item.item_id])}" class="info fn-left fn-f14">{$rs.item.name}
                        {if $rs.is_entrust}
                            {if $rs.fusion_state == 1}
                                <p class="gray"><span class="badge">寄卖中</span></p>
                            {else}
                                <p class="gray"><span class="badge bg-red">已提货</span></p>
                            {/if}
                        {else} 
                            <p class="gray"><span class="badge">待提货</span></p>
                        {/if}
                    </a>                    
                    <div class="number fn-right">￥{$rs.item.amount}</div>
                </div>
                {foreach $rs.gift as $key => $vo}
                <div class="fn-clear order">
                    <div class="img fn-left"><img src="{$vo.img}" /></div>
                    <a href="{:url('fastshop/item/edit',['id'=>$vo.item_id])}" class="info fn-left fn-f14">{$vo.name}
                        {if $rs.is_entrust}
                            {if $rs.fusion_state == 1}
                                <p class="gray"><span class="badge bg-green">已提货</span></p>
                            {else}
                                {if $rs.entrust[$key] == true}
                                    <p class="gray"><span class="badge">寄卖中</span></p>
                                {else}
                                    <p class="gray"><span class="badge bg-red">已提货</span></p>
                                {/if}
                            {/if}
                        {else} 
                            <p class="gray"><span class="badge">待提货</span></p>
                        {/if}
                    </a>
                    <div class="number fn-right">￥{$vo.sale_price}</div>
                </div>
                {/foreach}
            </td>
            <td class="fn-tac">￥{$rs.order_amount}</td>
            <td class="fn-tac">￥{$rs.real_amount}</td>            
        </tr>
    </tbody>

</table>
{/foreach}
<style type="text/css">
    .order {border-bottom: 1px #e9ecf3 solid}
    .order:first-child{background: #ebedf5}
    .order:last-child{border-bottom:none}
    .order div {margin: 5px;}
    .order .img {width: 80px;height: 80px;overflow: hidden;border: 1px dotted #e9ecf3;padding: 2px}
    .order .img img {width: 78px;}
    .order .info {line-height: 25px;margin-top: 10px;display: block;}
    .order .info .gray {color: #9e9e9e}
    .order .number {line-height: 50px;margin: 10px 20px;}
</style>
<script type="text/javascript">
    Do('base','layer',function () {
        $(".bar").click(function() {
            var url = $(this).attr('url');
            var msg = $(this).attr('msg');
            tools_submit({action:url,msg:msg})
        })
    })
</script>